#pragma once
#include <iostream>
#include <thread>
#include <vector>
#include <algorithm>
#include <mutex>
#include <map>
#include <shared_mutex>
#define MESSAGE "HTCK_DEVICE"
class Discovery {
    std::shared_mutex _readWriteLock;
    std::atomic<bool> _stop=false;
    std::map<std::string,int> _ips;
public:
    Discovery();
    ~Discovery() {_stop=true;}
    std::vector<std::string> getips(){
        std::vector<std::string> ips;
        {
            std::unique_lock<std::shared_mutex> lock(_readWriteLock);
            std::for_each(_ips.begin(),_ips.end(),[&](std::pair<const std::string,int>& it){ ips.emplace_back(it.first);});
        }
        return ips;
    }
};